package ru.urfc.portal.dao;

import java.util.List;

import ru.urfc.portal.dao.filter.Filter;
import ru.urfc.portal.model.Branch;
import ru.urfc.portal.model.SysObject;

public interface BasePersistence {
	
	<T> T persist(T entity);

	<T> T findById(Class<T> klass, Long id);

	<T> T findById(Class<T> klass, SpectrId spectrId);
	
	<T> List<T> find(Class<T> klass, String fieldName, Object value);

	<T> List<T> find(Branch branch, Class<T> klass, String fieldName, Object value);

	<T> List<T> find(Class<T> klass, Filter filter);

	<T> List<T> find(Branch branch, Class<T> klass, Filter filter);

	<T> List<T> findWhere(Branch branch, Class<T> klass, String expression, String orderBy, Paging paging, Object ... parameners);

	<T> void delete(Class<T> klass, String fieldName, Object value);

	<T> void delete(Class<T> klass, Long id);

	void delete(SysObject entity);

	void detach(SysObject ... entities);
	
	void flush();

}
